{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "formal-think",
   "metadata": {},
   "source": [
    "# 1. 编程准备\n",
    "## 学习目标\n",
    "1. 初识 Python\n",
    "    * 我们可以使用 Python 来做什么？\n",
    "    * Python 全球社区目前在做什么？\n",
    "    * Python 生态中有哪些有趣的项目？\n",
    "2. 熟悉编程环境: jupyterlab\n",
    "3. 设计第一个项目\n",
    "4. 认识字符串、变量、赋值、注释和 EIM 消息传递插件"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "prostate-street",
   "metadata": {},
   "source": [
    "## 编程准备\n",
    "打开[Scratch 创作](https://create.codelab.club/projects/editor/)页面，登陆自己的 CodeLab 账号，这样 Scratch 作品可以及时保存。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "racial-colorado",
   "metadata": {},
   "source": [
    "#### 编程相关单词\n",
    "- print：[prɪnt]，打印、印刷\n",
    "- client：[ˈklaɪənt]，客户端、客户\n",
    "- string：[strɪŋ]，字符串、一串\n",
    "- variable：[ˈvɛriəbəl]，变量、可变的\n",
    "- import：[ˈɪmpɔːrt]，导入、进口\n",
    "- send：[send]，发送、发射\n",
    "- message：[ˈmesɪdʒ]，消息、信息\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "missing-kruger",
   "metadata": {},
   "source": [
    "## 设置编程环境\n",
    "打开 Adapter, 在 WebUI 进入 JupyterLab 编程环境。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "median-robertson",
   "metadata": {},
   "source": [
    "## Hello World\n",
    "输入代码，按 Shift + Enter 键运行以下单元格看看会发生什么。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "upset-crack",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "41bef203-0b5d-4e45-9052-3a72b4d2d0a8",
   "metadata": {},
   "source": [
    "### 超级玛丽\n",
    "打印出 \n",
    "\n",
    "```\n",
    "#\n",
    "#\n",
    "#\n",
    "```\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a44b4261-52fd-456e-b29f-85d94d5ef1f6",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "342e4594-23a4-4ad4-a612-23a6a2b8d84f",
   "metadata": {},
   "source": [
    "打印出 `????`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "75497b1f-7d3b-4760-a1f6-20c2fa5beeb1",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "cf3f54cb-e60d-4d56-a817-f2c34afbcbe9",
   "metadata": {},
   "source": [
    "### debug"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "52542aad-1ce2-49b0-b69b-d570a7abd417",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid character in identifier (3493133067.py, line 1)",
     "output_type": "error",
     "traceback": [
      "\u001b[0;36m  File \u001b[0;32m\"/var/folders/7t/jb7df7tj65j832yzn_fjfhq40000gn/T/ipykernel_91561/3493133067.py\"\u001b[0;36m, line \u001b[0;32m1\u001b[0m\n\u001b[0;31m    print(“hello world”)\u001b[0m\n\u001b[0m               ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid character in identifier\n"
     ]
    }
   ],
   "source": [
    "print(“hello world”)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "8a38c6c1-2053-45d4-bb70-d8c6c9998fa8",
   "metadata": {},
   "outputs": [
    {
     "ename": "IndentationError",
     "evalue": "unexpected indent (207826295.py, line 2)",
     "output_type": "error",
     "traceback": [
      "\u001b[0;36m  File \u001b[0;32m\"/var/folders/7t/jb7df7tj65j832yzn_fjfhq40000gn/T/ipykernel_91561/207826295.py\"\u001b[0;36m, line \u001b[0;32m2\u001b[0m\n\u001b[0;31m    print(\"hello\")\u001b[0m\n\u001b[0m    ^\u001b[0m\n\u001b[0;31mIndentationError\u001b[0m\u001b[0;31m:\u001b[0m unexpected indent\n"
     ]
    }
   ],
   "source": [
    "print(\"hello world\")\n",
    "  print(\"hello\")\n",
    "print(\"world\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "advance-pavilion",
   "metadata": {},
   "source": [
    "## EIM 消息传递插件\n",
    "打开 [Scratch 创作](https://create.codelab.club/projects/editor/)页面，加载 EIM 消息传递插件，了解它的使用方法，并向 Scratch 发送一条消息。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "mexican-albany",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 从 Python 第三方库 codelab_adapter_client 中导入 send_message\n",
    "from codelab_adapter_client.message import send_message\n",
    "\n",
    "# 向 Scratch 发送一个 Hello World 的消息\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "strategic-habitat",
   "metadata": {},
   "source": [
    "打开 [【交互计算】Hello World](https://create.codelab.club/projects/7523/editor/) 项目，看看如何制作说话的动画。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "representative-trout",
   "metadata": {},
   "source": [
    "## 报菜名\n",
    "试一试将 Hello World 改成你想说的话。运行以下报菜名程序，看看效果怎么样？"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "incredible-input",
   "metadata": {},
   "outputs": [],
   "source": [
    "from codelab_adapter_client.message import send_message\n",
    "\n",
    "# 多行字符串用 3 个单引号或双引号括起来\n",
    "food = '''蒸羊羔、蒸熊掌、蒸鹿尾儿、烧花鸭、烧雏鸡、烧子鹅、卤猪、\n",
    "卤鸭、酱鸡、腊肉、松花小肚儿、晾肉、香肠儿、什锦苏盘、熏鸡白肚儿、\n",
    "清蒸八宝猪、江米酿鸭子、罐儿野鸡、罐儿鹌鹑、卤什件儿、卤子鹅'''\n",
    "send_message(food)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8206c192-0a74-4250-8a50-aec23227b882",
   "metadata": {},
   "source": [
    "### 试试多行字符串"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "21101d6d-469b-4da2-a920-e6e50a1d90fb",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "c1e82312-cacd-4e17-8d8d-b20493d09aba",
   "metadata": {},
   "source": [
    "### 变量的内容可能会变化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9db461f8-30d3-4aef-9450-9724225cc984",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 变量内容可以发生变化\n",
    "yummy_food1 = '麻婆豆腐'\n",
    "print(\"第1次的内容: \", yummy_food1)\n",
    "yummy_food1 = '鱼香肉丝'\n",
    "print(\"第2次的内容: \", yummy_food1)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "sunset-eight",
   "metadata": {},
   "source": [
    "## JupyterLab 快捷键\n",
    "使用快捷键可以更方便地操作单元格，使用快捷键时，先点击**选中**单元格，以下为 JupyterLab 中部分常用的快捷键：\n",
    "- A：在选中单元格的上方插入新单元格\n",
    "- B：在选中单元格的下方插入新单元格\n",
    "- D，D：按两次 D 键删除单元格\n",
    "- Shift + Enter：运行单元格\n",
    "- M：进入文本编辑模式\n",
    "- Y：进入代码编辑模式\n",
    "\n",
    "现在练习一下这些快捷键吧！"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "handmade-floating",
   "metadata": {},
   "source": [
    "### 作业"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "banned-graph",
   "metadata": {},
   "source": [
    "1. 在自己的电脑上安装 [Adapter](https://adapter.codelab.club/get_start/gs_install/)，探索 JupyterLab 的菜单栏，尝试单元格快捷键，并试试修改 JupyterLab 的主题。\n",
    "2. 让 Scratch 小猫报出你喜欢的事物，如食物、电影、动画。"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
